<?php
namespace app\index\model;

use app\admin\model\Base;

class VerifyCode extends Base {

	/**
	 * 发送短信
	 * $data['template_id']  短信模板ID
	 * $data['mobile']       手机号
	 * $data['param']        参数，json格式，如验证码 {"code":"'123456'"}
	 */
	public function send($data=[]){
		// 读取数据库阿里大于的配置
        $sms_config = get_config('sms_config');
		include_once ('./vendor/alidayu/TopSdk.php');
	    date_default_timezone_set('Asia/Shanghai');
		$c = new TopClient;
	//	$c -> format = 'json';
	//	$c -> simplify = true;
		$c -> appkey = $sms_config['app_key'];  
		$c -> secretKey = $sms_config['app_secret'];
		$req = new AlibabaAliqinFcSmsNumSendRequest;
		$req -> setSmsType("normal");
		$req -> setSmsFreeSignName($sms_config['app_sign']);
		$req -> setSmsParam($data['param']);
		$req -> setRecNum($data['mobile']);
		$req -> setSmsTemplateCode($data['template_id']);
		$resp = $c -> execute($req);
		return $resp;
	}

}
